/**
 */
package org.mro.grib.model.files.secondEdition.products.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;

import org.mro.grib.model.files.secondEdition.products.ProductDefinitionTemplate451;
import org.mro.grib.model.files.secondEdition.products.ProductsPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Product Definition Template451</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate451Impl#getNumberOfCategories <em>Number Of Categories</em>}</li>
 *   <li>{@link org.mro.grib.model.files.secondEdition.products.impl.ProductDefinitionTemplate451Impl#getCategoriesOffsets <em>Categories Offsets</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ProductDefinitionTemplate451Impl extends ProductDefinitionTemplate40Impl implements ProductDefinitionTemplate451 {
	/**
	 * The default value of the '{@link #getNumberOfCategories() <em>Number Of Categories</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfCategories()
	 * @generated
	 * @ordered
	 */
	protected static final byte NUMBER_OF_CATEGORIES_EDEFAULT = 0x00;

	/**
	 * The cached value of the '{@link #getNumberOfCategories() <em>Number Of Categories</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNumberOfCategories()
	 * @generated
	 * @ordered
	 */
	protected byte numberOfCategories = NUMBER_OF_CATEGORIES_EDEFAULT;

	/**
	 * The cached value of the '{@link #getCategoriesOffsets() <em>Categories Offsets</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCategoriesOffsets()
	 * @generated
	 * @ordered
	 */
	protected EList<Long> categoriesOffsets;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ProductDefinitionTemplate451Impl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ProductsPackage.Literals.PRODUCT_DEFINITION_TEMPLATE451;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public byte getNumberOfCategories() {
		return numberOfCategories;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNumberOfCategories(byte newNumberOfCategories) {
		byte oldNumberOfCategories = numberOfCategories;
		numberOfCategories = newNumberOfCategories;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE451__NUMBER_OF_CATEGORIES, oldNumberOfCategories, numberOfCategories));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Long> getCategoriesOffsets() {
		if (categoriesOffsets == null) {
			categoriesOffsets = new EDataTypeUniqueEList<Long>(Long.class, this, ProductsPackage.PRODUCT_DEFINITION_TEMPLATE451__CATEGORIES_OFFSETS);
		}
		return categoriesOffsets;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE451__NUMBER_OF_CATEGORIES:
				return getNumberOfCategories();
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE451__CATEGORIES_OFFSETS:
				return getCategoriesOffsets();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE451__NUMBER_OF_CATEGORIES:
				setNumberOfCategories((Byte)newValue);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE451__CATEGORIES_OFFSETS:
				getCategoriesOffsets().clear();
				getCategoriesOffsets().addAll((Collection<? extends Long>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE451__NUMBER_OF_CATEGORIES:
				setNumberOfCategories(NUMBER_OF_CATEGORIES_EDEFAULT);
				return;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE451__CATEGORIES_OFFSETS:
				getCategoriesOffsets().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE451__NUMBER_OF_CATEGORIES:
				return numberOfCategories != NUMBER_OF_CATEGORIES_EDEFAULT;
			case ProductsPackage.PRODUCT_DEFINITION_TEMPLATE451__CATEGORIES_OFFSETS:
				return categoriesOffsets != null && !categoriesOffsets.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (numberOfCategories: "); //$NON-NLS-1$
		result.append(numberOfCategories);
		result.append(", categoriesOffsets: "); //$NON-NLS-1$
		result.append(categoriesOffsets);
		result.append(')');
		return result.toString();
	}

} //ProductDefinitionTemplate451Impl
